package com.sheep.consumer;


import com.alibaba.dubbo.rpc.RpcContext;
import com.sheep.api.spark.SparkCommonService;
import com.sheep.api.util.ZipUtil;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Consumer {
    public static ApplicationContext springContext = null;

    public static void main(String[] args) throws Exception {
        PropertyConfigurator.configure(System.getProperty("user.dir") + "/conf/log4jprovider.properties");
        if (springContext == null) {
            springContext = new FileSystemXmlApplicationContext("conf/consumer.xml");
        }
        SparkCommonService sparkService = (SparkCommonService) springContext.getBean("sparkService");
        /** 单个测试 */
        String xml = ZipUtil.uncompress(sparkService.getADSBDataByCompress("2016", "05", "31", "B-5938", "MU728"));
        String serverIP = RpcContext.getContext().getRemoteHost();
        int serverPort = RpcContext.getContext().getRemotePort();
        System.out.println("rspInfo:" + xml + ", response from provider: " + serverIP + "," + serverPort);
    }

}
